﻿//
// Created by Administrator on 2025/7/4.
//
#include <iostream>
using namespace std;
class Animal {
public:
    virtual void speak() {
        std::cout << "Animal speaks" << std::endl;
    }
};

class Dog : public Animal {
public:
    void speak() override {
        std::cout << "Dog barks" << std::endl;
    }
};

int main() {
    Animal* a = new Dog();
    a->speak();  // 输出：Dog barks ✅
}
